<template>
	<view>
		<view class="topContent">
			<!-- 用户昵称 -->
			<u-row>
				<u-col span="3">
					<view class="userInfoLeft">
						<u-avatar src="/static/img/user.png" size="180" @click="toLogin"></u-avatar>
					</view>
				</u-col>
				<u-col span="9">
					<view v-if="userInfo.isLogin" class="userInfoRight">
						<view class="name">用户名：{{name}}</view>
						<view class="info">
							个人简介：{{text}}
						</view>
					</view>
					<view v-else class="userInfoRight">
						<view class="login-container">
							<!-- 登录方式选择区域 -->
							<view class="login-methods">
								<!-- 微信一键登录 -->
								<view class="login-btn wechat-btn" @click="handleWechatLogin">
									<u-icon name="weixin-fill" color="#09BB07" size="50"></u-icon>
									<text style="margin-left: 5px;">微信一键登录</text>
								</view>

								<!-- 账号密码登录 -->
								<view class="login-btn account-btn" @click="showAccountLogin = true">
									<u-icon name="account-fill" color="#2979ff" size="50"></u-icon>
									<text style="margin-left: 5px;">账号密码登录</text>
								</view>
							</view>
						</view>
					</view>
				</u-col>
			</u-row>
		</view>


		<!-- 用户主题信息部分 -->

		<!-- 内容部分 -->
		<view class="weather-cards">
			<!-- 第一行 -->
			<view class="weather-card">
				<view class="card-icon">
					<u-icon name="star-fill" color="#FFAA00" size="80"></u-icon>
				</view>
				<view class="card-content">
					<view class="card-value">{{userInfo.followCount}} 人</view>
					<view class="card-label">关注人数</view>
				</view>
			</view>

			<view class="weather-card">
				<view class="card-icon">
					<u-icon name="account-fill" color="#19BE6B" size="80"></u-icon>
				</view>
				<view class="card-content">
					<view class="card-value">{{userInfo.registerDays}} 天</view>
					<view class="card-label">累计使用</view>
				</view>
			</view>

			<!-- 第二行 -->
			<view class="weather-card">
				<view class="card-icon">
					<u-icon name="tags-fill" color="#2979FF" size="80"></u-icon>
				</view>
				<view class="card-content">
					<text class="card-value">实用工具</text>
					<text class="card-label">使用工具</text>
				</view>
			</view>

			<view class="weather-card">
				<view class="card-icon">
					<u-icon name="setting-fill" color="#909399" size="80"></u-icon>
				</view>
				<view class="card-content">
					<text class="card-value">我的设置</text>
					<text class="card-label">个性设置</text>
				</view>
			</view>
		</view>

		<!-- 在线客服 -->
		<view class="content">
			<u-row>
				<u-col span="2">
					<view>
						<u-icon name="chat-fill" style="font-size: 50px;
						margin-top: 10px;color: #fd973e;"></u-icon>
					</view>
				</u-col>
				<u-col span="10">
					<view>
						<view style="font-size: 20px;margin-top: 5px;font-weight: 800;">联系我们</view>
						<view style="font-size: 16px;margin-top: 5px;">
							反馈、投诉、建议 知你冷暖、在你身边
						</view>
					</view>
				</u-col>
			</u-row>
		</view>

		<view class="viewSwiper">
			<u-swiper :list="list" keyName="image" showTitle="true" :autoplay="true" circular height="300"></u-swiper>
		</view>

		<u-modal v-model="showAccountLogin" title="账号登录" :show-cancel-button="true">
			<view class="account-form">
				<u-input v-model="userInfo.account" placeholder="请输入账号" border></u-input>
				<u-input v-model="userInfo.password" placeholder="请输入密码" password border></u-input>
			</view>
			<template #confirm-button>
				<u-button @click="handleAccountLogin">登录</u-button>
			</template>
		</u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '凌明磊',
				text: '✨ 热爱生活，追逐星光，简单快乐,永远在路上，努力发光发热。',
				userInfo: {
					registerDays: 365, // 注册天数（示例数据）
					followCount: 42, // 关注用户数（示例数据）
					isLogin: false,
					account: '',//账号
					password: ''//密码
				},
				list: [{
						image: "https://static-o.oss-cn-shenzhen.aliyuncs.com/images/tpbj/ImitatePhotoStyle1.jpg",
						title: "昨夜星辰昨夜风，画楼西畔桂堂东",
					},
					{
						image: "https://static-o.oss-cn-shenzhen.aliyuncs.com/images/tpbj/tpss05.jpg",
						title: "身无彩凤双飞翼，心有灵犀一点通",
					}, {
						image: "https://static-o.oss-cn-shenzhen.aliyuncs.com/images/tpbj/zmcc08.jpg",
						title: "谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳",
					}
				],
				showAccountLogin: false //登录弹框
			}
		},
		methods: {
			/**
			 * 做登录状态切换
			 */
			toLogin() {
				console.log('做登录状态切换！！！')
				this.userInfo.isLogin = !this.userInfo.isLogin
			},

			/**
			 * 微信登录
			 */
			handleWechatLogin() {
				console.log('处理微信登录！！！')
			},
			/**
			 * 使用账号密码登录
			 */
			handleAccountLogin(){
				console.log('使用账号密码登录')
				console.log('登录账号为：' + this.userInfo.account)
				console.log('登录密码为：' + this.userInfo.password)
				
				uni.showToast({
				  title: '登录成功', 
				  icon: 'success',  
				  duration: 2000   
				});
				
				this.showAccountLogin = false
			}
		}
	}
</script>

<style>
	.topContent {
		border-radius: 10px;
		/* 圆角 */
		border: 1px solid #ebeef5;
		/* 边框颜色 */
		background-color: #fff;
		/* 背景色 */
		box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.15);
		/* 阴影 */
		transition: box-shadow 0.3s;
		/* 悬停动画 */
		margin-bottom: 20px;
		/* 卡片间距 */
		margin: 10px;
		height: 120px;
	}

	.userInfoLeft {
		height: 100px;
		width: 100px;
		padding: 10px;
	}

	.userInfoRight {
		height: 100px;
		padding: 20px;
		font-size: 13px;
	}

	.userInfoRight .name {
		font-size: 18px;
	}

	.userInfoRight .info {
		margin-top: 5px;
		font-size: 14px;
	}

	.content {
		border-radius: 10px;
		/* 圆角 */
		border: 1px solid #ebeef5;
		/* 边框颜色 */
		background-color: #fff;
		/* 背景色 */
		box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.15);
		/* 阴影 */
		transition: box-shadow 0.3s;
		/* 悬停动画 */
		margin-bottom: 20px;
		/* 卡片间距 */
		margin: 10px;
		padding: 20px;
		margin-bottom: 20px;
	}

	.container {
		padding: 20rpx;
		background-color: #f7f7f7;
	}

	/* 卡片网格布局 */
	.card-grid {
		display: flex;
		flex-direction: column;
		gap: 20rpx;
	}

	.weather-cards {
		display: flex;
		flex-wrap: wrap;
		/* 允许换行 */
		gap: 16px;
		/* 卡片间距 */
		padding: 12px;
	}

	.weather-card {
		width: calc(50% - 8px);
		/* 一行两个，考虑gap */
		background: #fff;
		border-radius: 12px;
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
		/* 阴影 */
		padding: 16px;
		display: flex;
		align-items: center;
		transition: transform 0.3s, box-shadow 0.3s;
	}

	.weather-card:hover {
		transform: translateY(-4px);
		box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
		background-color: #E0E0E0;
	}

	.card-value {
		font-size: 20px;
		font-weight: bold;
		color: #333;
	}

	.card-label {
		text-align: center;
		font-size: 18px;
		color: #666;
		margin-top: 4px;
	}

	.card-content {
		display: flex;
		flex-direction: column;
		margin-left: 10px;
	}

	.viewSwiper {
		margin-top: 50px;
		border-radius: 10px;
		/* 圆角 */
		border: 1px solid #ebeef5;
		/* 边框颜色 */
		background-color: #fff;
		/* 背景色 */
		box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.15);
		/* 阴影 */
		transition: box-shadow 0.3s;
		/* 悬停动画 */
		margin-bottom: 20px;
		/* 卡片间距 */
		margin: 10px;
		padding: 0px;
	}

	.login-container {
		padding: 5rpx;
		margin: 0px;
	}

	.login-methods {
		display: flex;
		flex-direction: column;
		gap: 20rpx;
	}

	.login-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 40rpx;
		border-radius: 45rpx;
		font-size: 32rpx;
	}

	.wechat-btn {
		background-color: #f1f1f1;
		color: #333;
		height: 40px;
	}

	.account-btn {
		background-color: #f1f1f1;
		color: #333;
		height: 40px;
	}
	
	.account-form {
	  padding: 30rpx;
	}
</style>